<template>
  <div>
    <div id="main" style="width: 600px; height: 400px"></div>
    <div id="aaa" style="width: 600px; height: 10px;text-align: center;  "><font color="red">每个路段订单数</font></div>
    <div id="main1" style="width: 600px; height: 400px; text-align: center;"></div>
    
  </div>
</template>

<script>
export default {
  data() {
    return {
      echartList: [],
      secNameList:[],
      orderNumList:[]
    };
  },
  methods: {
    loadOrderStatusEchart() {
      this.$axios.get("order/echart").then((res) => {
        this.echartList = res.data.data.echartList;
        this.getChar();
        
      });
    },
    loadSecOrder(){
      this.$axios.get("sections/echart").then((res) => {
        this.secNameList = res.data.data.secNameList;
        this.orderNumList = res.data.data.orderNumList;
        this.getChar1();
        
      });
    },
    getChar() {
      var myChart = this.$echarts.init(document.getElementById("main"));
      var option = {
        title: {
          text: "订单统计图",
          subtext: "订单情况统计",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        color: [
          "#fc8251",
          "#5470c6",
          "#91cd77",
          "#ef6567",
          "#f9c956",
          "#75bedc",
        ],
        series: [
          {
            name: "数量",
            type: "pie",
            radius: "50%",
            data: this.echartList,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      myChart.setOption(option);
    },
    getChar1() {
      var myChart1 = this.$echarts.init(document.getElementById("main1"));
      var option = {
        xAxis: {
          
          type: "category",
          data: this.secNameList,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: this.orderNumList,
            type: "line",
          },
        ],
      };
      myChart1.setOption(option);
    },
  },
  mounted() {
    this.loadOrderStatusEchart();
    this.loadSecOrder();
  },
};
</script>